//
//  SYHeaderView.m
//  BShouGongKe
//
//  Created by lanou on 15/8/11.
//  Copyright (c) 2015年 L750. All rights reserved.
//

#import "SYHeaderView.h"
#import "Header.h"
#import "SYMomentsTypeModel.h"
#import <UIImageView+WebCache.h>

@implementation SYHeaderView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {

        _pictureView = [[UIImageView alloc]init];
        _pictureView.frame = CGRectMake(10, 10, 60, 60);
        _pictureView.backgroundColor = [UIColor grayColor];
        [self addSubview:_pictureView];
        
        _textLabel = [[UILabel alloc]init];
        _textLabel.font = [UIFont systemFontOfSize:15];
        _textLabel.numberOfLines = 0;
        _textLabel.textAlignment = NSTextAlignmentLeft;
        _textLabel.textColor = [UIColor colorWithRed:100 / 255.0 green:100 / 255.0 blue:100 / 255.0 alpha:1];
        [self addSubview:_textLabel];
        
        _lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 0.3)];
        _lineView.backgroundColor =[UIColor grayColor];
        [self addSubview:_lineView];
        
        _lineView2 = [[UIView alloc]initWithFrame:CGRectMake(0, 79.7, SCREEN_WIDTH, 0.3)];
        _lineView2.backgroundColor = [UIColor grayColor];
        [self addSubview:_lineView2];
        
        _backgroundView = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH - 60, 22.5, 35, 35)];
        _backgroundView.image = [UIImage imageNamed:@"quan_detail_btn_bg_h@3x"];
        _backgroundView.userInteractionEnabled = YES;
        [self addSubview:_backgroundView];
        
        _addButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _addButton.frame = CGRectMake(5, 5, 25, 25);
        
        //_addButton.layer.borderColor = [UIColor redColor].CGColor;
        //_backgroundView.layer.borderWidth = 0.5;
        _backgroundView.layer.shadowColor = [UIColor grayColor].CGColor;
        _backgroundView.layer.shadowOffset = CGSizeMake(0, 1);
        _backgroundView.layer.shadowOpacity = 0.8;
        _backgroundView.layer.shadowRadius = 0.2;
        
        
        [_addButton setBackgroundImage:[UIImage imageNamed:@"quan_detail_add@3x"] forState:UIControlStateNormal];
        [_backgroundView addSubview:_addButton];
        [_addButton addTarget:self action:@selector(doAddQuanzi:) forControlEvents:UIControlEventTouchUpInside];

    }
    return self;
}


- (void)setModel:(SYMomentsTypeModel *)model{
    _textLabel.text = model.quan_slogan;
    CGFloat height = [_textLabel.text boundingRectWithSize:CGSizeMake(80, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:15] forKey:NSFontAttributeName] context:nil].size.height;
    _textLabel.frame = CGRectMake(80, 10, SCREEN_WIDTH - 160, height);
    [_pictureView sd_setImageWithURL:[NSURL URLWithString:model.quan_logo]];
}

- (void)doAddQuanzi:(UIButton *)sender{
    if (_delegate && [_delegate respondsToSelector:@selector(collectionQuanzi)]) {
        [_delegate performSelector:@selector(collectionQuanzi)];
    }
}



@end
